
package com.gamatechno.solodestinationnew;

import java.util.ArrayList;
import java.util.HashMap;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.gamatechno.solodestinationnew.utils.Webservice;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.SimpleImageLoadingListener;

public class EventDetailActivity extends BaseActivity {

    String Lat;
    String Lon;
    Bitmap bmp;
    String URL_IMG;
    ImageView imageEvent, iconMap;
    ProgressBar load;
    TextView namaEvent, detailEvent, catEvent, start, end;

    private WebView wvDetail;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_event_detail);

        load = (ProgressBar) findViewById(R.id.load);
        load.bringToFront();
        namaEvent = (TextView) findViewById(R.id.namaEvent);
        // iconMap = (ImageView) findViewById(R.id.iconmap);
        wvDetail = (WebView) findViewById(R.id.webview_detail);
        // detailEvent = (TextView) findViewById(R.id.detailEvent);
        catEvent = (TextView) findViewById(R.id.categoryEvent);
        imageEvent = (ImageView) findViewById(R.id.imageEvent);
        start = (TextView) findViewById(R.id.startDate);
        end = (TextView) findViewById(R.id.EndDate);

        ArrayList<HashMap<String, Object>> data = (ArrayList<HashMap<String, Object>>) getIntent()
                .getSerializableExtra("detail");

        for (int i = 0; i < data.size(); i++) {
            // tglEvent.setText(data.get(i).get("startDate").toString());
            namaEvent.setText(data.get(i).get("nama").toString());

            wvDetail.loadData(data.get(i).get("description").toString(), "text/html", "utf-8");

            catEvent.setText(data.get(i).get("category").toString());
            start.setText(data.get(i).get("startDate").toString());
            end.setText(data.get(i).get("endDate").toString());

            URL_IMG = Webservice.EVENT_FILE + data.get(i).get("image").toString();
            ImageLoader.getInstance().displayImage(URL_IMG, imageEvent,
                    BaseApplication.getDisplayImageOptions(),
                    new SimpleImageLoadingListener() {
                        @Override
                        public void onLoadingComplete(String imageUri,
                                View view, Bitmap loadedImage) {
                            super.onLoadingComplete(imageUri, view, loadedImage);
                            if (load != null)
                                load.setVisibility(View.GONE);
                        }
                    });
        }

    }
}
